#@head() 
#@header()
<title>红包详情</title>
#@aside("marketing")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<style>
	.box-body{padding:5px !important}
</style>
<div class="content-wrapper">
	<section class="content">
	<div class="nav-tabs-custom">
		<ul class="nav nav-tabs">
			<li class="active"><a href="#(path)/admin/page/marketing-apphelp" >详情</a></li>
		</ul>
		<div class="tab-content">
		  <div class="tab-pane active" id="tab_1">
			<div class="box-body">
			<table id="example1" class="table table-bordered table-striped dataTable col-md-8" role="grid" aria-describedby="example1_info">
				<tbody>
				<tr role="row" class="even">
				  <td align="right" style="width:130px;" class="sorting_1">类型：</td>
				  <td id="type" class="sorting_1"></td>
				</tr>
				<tr role="row" class="odd">
				  <td align="right" style="width:130px;" class="sorting_1">名称：</td>
				  <td id="name" class="sorting_1"></td>
				</tr>
				<tr role="row" class="even">
				  <td align="right" style="width:130px;" class="sorting_1">状态：</td>
				  <td id="status" class="sorting_1"></td>
				</tr>
				<tr role="row" class="odd">
				  <td align="right" style="width:130px;" class="sorting_1">发放数量：</td>
				  <td class="sorting_1"><a id="apply_num"></a>/<a id="num" ></a>张</td>
				</tr>
				<tr role="row" class="odd">
				  <td align="right" style="width:130px;" class="sorting_1">投资满可用：</td>
				  <td id="limit_amount" class="sorting_1"></td>
				</tr>
				<tr role="row" class="odd">
				  <td align="right" style="width:130px;" class="sorting_1">可否重复领取：</td>
				  <td id="is_repeat" class="sorting_1"></td>
				</tr>
				<tr role="row" class="even">
				  <td align="right" style="width:130px;" class="sorting_1">活动时间：</td>
				  <td class="sorting_1"><span id="start_time"></span> 至 <span id="end_time"></span></td>
				</tr>
				<tr role="row" class="odd">
				  <td align="right" style="width:130px;" class="sorting_1">红包有效期：</td>
				  <td class="sorting_1"><span id="validtime"></span></td>
				</tr>
				<tr role="row" class="odd">
				  <td align="right" style="width:130px;" class="sorting_1">发放规则：</td>
				  <td id="rule_amount1" class="sorting_1"></td>
				</tr>
				<tr role="row" class="odd">
				  <td align="right" style="width:130px;" class="sorting_1">活动链接</td>
				  <td id="link" class="sorting_1"></td>
				</tr>
				</tbody>
			</table>
			</div>
		</div>
	</div>
	</section>
</div>
#@footer()
<script>
$(document).ready(function(){
	var id = GetRequest(id);
	 
	$.getJSON("/coupon/info?token=#(session.token??)&id="+id.id, function(datainfo) {
		 console.log(datainfo);
		var datainfo = datainfo.data.item;
		setFormVals(datainfo);
		if(datainfo.rule=="reg"){
			var rule_amount = datainfo.rule_amount;
			$("#rule_amount1").html("注册送"+rule_amount+"元");
		}else if(datainfo.rule=="real"){
			var rule_amount = datainfo.rule_amount;
			$("#rule_amount1").html("实名送"+rule_amount+"元");
		}else if(datainfo.rule=="direct"){
			$("#rule_amount1").html("定向发放");
		}else {
			var rule_amount = JSON.parse(datainfo.rule_amount);
			$("#rule_amount1").append("<span>投资满 "+rule_amount.target+" 送 "+rule_amount.amount+"元 （"+(rule_amount.increase=='1'?"递增":"不递增")+"）</span><br>");
		}
		var limit_amount = "";
		if(datainfo.type=='tzhb' || datainfo.type=='jxq'){
			var limit_amount = JSON.parse(datainfo.limit_amount);
			limit_amount = "<span>投资满 "+limit_amount.target+" 送 "+limit_amount.amount+"元 （"+(limit_amount.increase=='1'?"递增":"不递增")+"）</span><br>";
		}else{
			limit_amount = "<span>满"+datainfo.limit_amount+"元可用</span>";
		}
		
		$("#limit_amount").html(limit_amount); 
		if(datainfo.valid_day == 0){
			var validtime = datainfo.valid_start_time + " 至 " +datainfo.valid_end_time;
		}else {
			var validtime = "自领取"+ datainfo.valid_day + "天内";
		}
		$("#validtime").html(validtime);
		if(datainfo.status=="disable"){$("#status").html("停用");}else if(datainfo.status=="enable"){$("#status").html("启用");}
			else if(datainfo.status=="stop"){$("#status").html("手动结束");}else if(datainfo.status=="finish"){$("#status").html("发放完毕");}
		if(datainfo.type=="tzhb"){$("#type").html("返现券");}else if(datainfo.type=="tyj"){$("#type").html("体验金");}
			else if(datainfo.type=="jxq"){$("#type").html("加息券");}
		if(datainfo.is_repeat=='0'){
			$("#is_repeat").html("不可重复领取");
		}else{
			$("#is_repeat").html("可重复领取");
		}
	});
});

function GetRequest() {  
   var url = location.search; //获取url中"?"符后的字串  
   var theRequest = new Object();  
   if (url.indexOf("?") != -1) {  
      var str = url.substr(1);  
      strs = str.split("&");  
      for(var i = 0; i < strs.length; i ++) {  
         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
      }  
   }  
   return theRequest;  
}  
</script>
</body>
</html>